package src;

/**
 * 数组队列
 */
public class ArrayQueue<E> implements Queue<E> {

    private Array<E> array;

    public ArrayQueue(int capacity){
        array = new Array<>(capacity);
    }
    public ArrayQueue(){
        array = new Array<>();
    }

    @Override
    public int getSize() {
        return array.getSize();
    }

    @Override
    public boolean isEmpty() {
        return array.isEmpty();
    }

    @Override
    public void enQueue(E e) {
        array.addLast(e);
    }

    @Override
    public E deQueue() {
        return array.removeFirst();
    }

    @Override
    public E getFront() {
        return array.get(0);
    }

    public int getCapacity() {
        return array.getCapacity();
    }

    @Override
    public String toString(){
        StringBuffer res = new StringBuffer();
        res.append("Queue: <--");
        res.append(array.toString());
        res.append("<--");
        return res.toString();
    }
}